package com.AJava1710D.设计模式.单例.饿汉式;


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 作者: LCG
 * 日期: 2020/6/29 09:03
 * 描述:
 */
public class TestEHanShi {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        EHanShi instance = EHanShi.getInstance();

        FutureTask<EHanShi> futureTask=new FutureTask<>(new Callable<EHanShi>() {
            @Override
            public EHanShi call() throws Exception {
                return EHanShi.getInstance();
            }
        });
        Thread thread=new Thread(futureTask);


        FutureTask<EHanShi> futureTask2=new FutureTask<>(new Callable<EHanShi>() {
            @Override
            public EHanShi call() throws Exception {
                return EHanShi.getInstance();
            }
        });
        Thread thread2=new Thread(futureTask2);


        FutureTask<EHanShi> futureTask3=new FutureTask<>(new Callable<EHanShi>() {
            @Override
            public EHanShi call() throws Exception {
                return EHanShi.getInstance();
            }
        });
        Thread thread3=new Thread(futureTask3);


        thread.start();
        thread2.start();
        thread3.start();

        EHanShi eHanShi = futureTask.get();

        EHanShi eHanShi1 = futureTask2.get();

        EHanShi eHanShi2 = futureTask3.get();

        System.out.println(eHanShi==eHanShi1);
        System.out.println(eHanShi==eHanShi2);
        System.out.println(eHanShi1==eHanShi2);


    }

}
